<template>
    <div>
        <el-steps :space="200" :active="add" align-center="true" finish-status="success" class="step">
            <el-step title="基本信息"></el-step>
            <el-step title="产品参数配置"></el-step>
            <el-step title="申请材料配置"></el-step>
            <el-step title="基本信息"></el-step>
            <el-step title="产品参数配置"></el-step>
            <el-step title="申请材料配置"></el-step>
        </el-steps>

        <el-card class="box-card" body-style="">
            <el-row>
                <div>
                    <el-form :inline="true" :label-position="top" v-model="addProduct"  ref="addProduct" label-width="auto" style="float:left">
                        <el-form-item label="用户真实姓名">
                            <el-input v-model="addProduct.userinfoRealname"></el-input>
                        </el-form-item>

                        <el-form-item label="用户手机号码">
                            <el-input v-model="addProduct.userinfoTel"></el-input>
                        </el-form-item>
                        
                        <el-form-item label="用户身份证">
                            <el-input v-model="addProduct.userinfoCardNo"></el-input>
                        </el-form-item>

                        <el-form-item label="用户籍贯信息">
                            <el-input v-model="addProduct.userinfoNativePlace"></el-input>
                        </el-form-item>
                        <el-form-item label="用户婚姻情况">
                            <el-input v-model="addProduct.userinfoMaritaStatus"></el-input>
                        </el-form-item>

                        <el-form-item label="用户学历">
                            <el-input v-model="addProduct.userinfoDegree"></el-input>
                        </el-form-item>
                        <el-form-item label="用户现居住地">
                            <el-input v-model="addProduct.userinfoCurrentResidence"></el-input>
                        </el-form-item>

                        <el-form-item label="直属亲属姓名">
                            <el-input v-model="addProduct.userinfoImmediateRelative"></el-input>
                        </el-form-item>
                        <el-form-item label="直属亲属关系">
                            <el-input v-model="addProduct.userinfoRelationship"></el-input>
                        </el-form-item>

                        <el-form-item label="直属亲属手机号码">
                            <el-input v-model="addProduct.userinfoRelationshipPhone"></el-input>
                        </el-form-item>

   
                        <el-form-item label="银行">
                            <el-col :span="6">
                                <el-select v-model="addProduct.bankId" placeholder="请选择">
                                    <el-option v-for="(bank, index) in bankList" :key="index" :label="bank.bankName"
                                        :value="bank.bankId">
                                    </el-option>
                                </el-select>
                            </el-col>
                        </el-form-item>

                        <el-form-item label="用户工作公司">
                            <el-input v-model="addProduct.companyName"></el-input>
                        </el-form-item>
                        <el-form-item label="用户工作公司地址">
                            <el-input v-model="addProduct.companyAddress"></el-input>
                        </el-form-item>

                        <el-form-item label="用户工作公司性质">
                            <el-input v-model="addProduct.companyDetailedAddress"></el-input>
                        </el-form-item>
                        <el-form-item label="用户工作公司行业">
                            <el-input v-model="addProduct.companyNature"></el-input>
                        </el-form-item>
                        <el-form-item label="用户工作公司联系方式">
                            <el-input v-model="addProduct.companyTel"></el-input>
                        </el-form-item>
                        <el-form-item label="用户每月收入">
                            <el-input v-model="addProduct.userinfoIncome"></el-input>
                        </el-form-item>
                        <el-form-item label="入职时长">
                            <el-input v-model="addProduct.userinfoEntryTime"></el-input>
                        </el-form-item>
                      


                        <el-form-item label="手持正面身份证照">
                            <el-upload class="avatar-uploader"
                                action="http://localhost:8080/products/uploadProductCover" name="addProduct.userinfoFrontPhoto"
                                :show-file-list="false" :on-success="handleSuccess" :before-upload="beforerUpload">
                                <img v-if="imageUrl" :src="imageUrl" class="avatar">
                                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                            </el-upload>
                        </el-form-item>
                        <el-form-item label="手持正面身份证照">
                            <el-upload class="avatar-uploader"
                                action="http://localhost:8080/products/uploadProductCover" name="addProduct.userinfoReversePhoto"
                                :show-file-list="false" :on-success="handleSuccess" :before-upload="beforerUpload">
                                <img v-if="imageUrl" :src="imageUrl" class="avatar">
                                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                            </el-upload>
                        </el-form-item>
                        
                         <el-form-item label="手持正面身份证照">
                            <el-upload class="avatar-uploader"
                                action="http://localhost:8080/products/uploadProductCover" name="addProduct.holdFrontPhoto"
                                :show-file-list="false" :on-success="handleSuccess" :before-upload="beforerUpload">
                                <img v-if="imageUrl" :src="imageUrl" class="avatar">
                                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                            </el-upload>
                        </el-form-item>
                        <el-row>
                            <el-button type="primary" @click="pushInfoUser">提交信息</el-button>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <el-button type="warning" >取消</el-button>
                        </el-row>
                    </el-form>
                 
                </div>
                <div>
                  
                </div>
            </el-row>
        </el-card>
    </div>
</template>

<script>


export default {
    data() {
        return {
            add:"3",
            imageUrl: "",
            addProduct: {},
            contractTemplateList: {},
            bankList: {},
            repayMethodList: {},
            contractList: {}
        };
    },
    methods: {
        handleSuccess(res, file) {
            this.imageUrl = res.message;
            this.addProduct.productCover = res.message;
        },
        beforeUpload(file) {
            const isJPG = file.type === 'image/jpeg';
            const isLt2M = file.size / 1024 / 1024 < 10;

            if (!isJPG) {
                this.$message.error('上传头像图片只能是 JPG 格式!');
            }
            if (!isLt2M) {
                this.$message.error('上传头像图片大小不能超过 10MB!');
            }
            return isJPG && isLt2M;
        },
        loadContractTemplate() {
            this.$axios.get("/contracts").then((res) => {
                this.contractTemplateList = res.data.data.contractTemplateList;
            });
        },
        loadBank() {
            this.$axios.get("/contracts").then((res) => {
                this.bankList = res.data.data.bankList;
            });
        },
        loadRepayMethod() {
            this.$axios.post("/repayRecord/queryAll").then((res) => {
                this.repayMethodList = res.data.data.repayMethodList;
            });
        },
        loadContract() {
            this.$axios.get("/contracts").then((res) => {
                this.contractList = res.data.data.contractList;
            });
        },
        addP() {
            this.$axios.post("products/add", this.addProduct).then((res) => {
                alert(qqqqqqqqq);
                if (res.data.code == 200) {
                    this.$refs.addProduct.resetFields();
                }
            });
        },

        /**
         * 提交信息
         */
        pushInfoUser(){
            this.$router.push("/Debit");
            this.$axios.post("products/add", this.addProduct).then((res) => {
                if (res.data.code == 200) {
                    this.$router.push("/Debit");
                }
            }); 
        }
    },
    mounted() {
        this.loadContract();
        this.loadBank();
        this.loadRepayMethod();
        this.loadContractTemplate();
    }
};
</script>

<style>
.text {
    font-size: 14px;
}

.item {
    margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
    display: table;
    content: "";
}

.clearfix:after {
    clear: both
}

.box-card {
    width: 1200px;
    margin: 10px auto;
    margin-top: 40px;
}

.step {
    margin-top: 30px;
    margin-left: 525px;
}

.step2 {
    margin-top: 60px;
    margin-left: 180px;
}

.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.avatar-uploader .el-upload:hover {
    border-color: #409EFF;
}

.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}

.avatar {
    width: 178px;
    height: 178px;
    display: block;
}
</style>